require.config({baseUrl: '/js/lib',urlArgs: "v0.0.1"});
require(['zepto', 'lib'], function($, lib) {
  var fn = {}, lib = new lib();
  $.extend(fn, {
    init: function(){
      
      this.getAccountInfo();
      this.bindEvent();
    },
    bindEvent: function(){
      $(document).on('tap', '.ui-nav i', function(data){
        location.href = './account_set.html';
      });
    },
    getAccountInfo: function(){
      lib.onLoading();
      lib.ajx(lib.getReq().ser + 'sellerCenter/getAccountInfo.action', {searchType: 1}, function(data){
        if(data.infocode === "0"){
          var h =  `<div class="ui-balance-info">
                      <a href="#">账户余额(元)</a>
                      <a href="#">${data.info.totalBalance}</a>
                    </div>
                    
                    <ul class="ui-balance-detail">
                      <li>
                        <a href="#">
                          <p>总收益(元)</p>
                          <p>${data.info.totalRevenue　}</p>
                        </a>
                      </li>
                      <li>
                        <a href="#">
                          <p>转出金额(元)</p>
                          <p>${data.info.transferAmount}</p>
                        </a>
                      </li>
                      <li>
                        <a href="#">
                          <p>到账金额(元)</p>
                          <p>${data.info.arrivalAmount}</p>
                        </a>
                      </li>
                    </ul>`;
          $(".ui-balance-info, .ui-balance-detail").remove();
          $(".ui-index-header").append(h);
        }else if(data.infocode === "2"){
          location.href = './login.html?backUrl=' + lib.getBackUrl();
        }else{
          lib.showMessage(data.info);
        }
      }, function(){
        lib.showMessage("网络延时，请稍后再试");
      });
    }
  });
  
  fn.init();
});